﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InstancingScript 
    : MonoBehaviour
{
    public MeshRenderer redCube;
    public MeshRenderer greenCube;
    public MeshFilter filter;

    private void Start()
    {
        //通过MaterialPropertyBlock传递属性，避免实例化材质，打断实例化绘制
        MaterialPropertyBlock mpb = new MaterialPropertyBlock();

        redCube.GetPropertyBlock(mpb);
        mpb.SetColor("_Color", Color.red);
        redCube.SetPropertyBlock(mpb);

        greenCube.GetPropertyBlock(mpb);
        mpb.SetColor("_Color", Color.green);
        greenCube.SetPropertyBlock(mpb);
    }
}
